<template>
  <dv-scroll-board
    :config="config"
    style="width: 100%; height: 100%; margin-left: 0.5rem"
    class="listcls"
    @click="openDetail"
  />
  <bgb-table ref="dialogRef" v-if="dialog.bgbtable" @closed="dialog.bgbtable = false"></bgb-table>
</template>
<script>
import dprevent from '@/api/dprevent'
import BgbTable from './BgbTable.vue'

export default {
  components: { BgbTable },
  data() {
    return {
      dialog: {
        bgbtable: false
      },
      config: {
        data: [],
        oddRowBGC: 'transparent',
        evenRowBGC: 'transparent',
        index: true,
        columnWidth: [40],
        align: ['center']
      }
    }
  },
  mounted() {
    this.getApiData()
    setInterval(() => {
      this.getApiData()
    }, 5000)
  },
  methods: {
    getApiData() {
      dprevent.dprightapi3().then((res) => {
        if (res.code === 'success') {
          if (res.result) {
            this.config.data = res.result
          }
        }
      })
    },
    openDetail() {
      this.dialog.bgbtable = true
      this.$nextTick(() => {
        this.$refs.dialogRef.open()
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.dv-scroll-board :deep(.row-item) {
  font-size: 12px;
}
</style>
